<template>
  <div class="app-container">
    <el-form ref="queryForm" :model="form" :inline="true">
      <el-form-item label="用户ID" prop="userId">
        <el-input placeholder="用户ID" v-model="form.userId"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery('queryForm')">查询</el-button>
      </el-form-item>
    </el-form>

    <!-- 用户贡献统计 -->
    <el-table :data="tableData" style="width: 100%" v-loading="loading">
      <el-table-column prop="userId" label="ID"></el-table-column>
      <el-table-column prop="userAccount" label="会员账号"></el-table-column>
      <el-table-column prop="coinName" label="币种"></el-table-column>
      <el-table-column prop="transAmount" label="交易额"></el-table-column>
      <el-table-column prop="depositAmount" label="充值总数"></el-table-column>
      <el-table-column prop="withdrawAmount" label="提现总数"></el-table-column>
      <el-table-column prop="transFee" label="交易手续费"></el-table-column>
      <el-table-column prop="withdrawFee" label="提币手续费"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { userContributionStatistics } from "@/api/home/contribution"
export default {
  data() {
    return {
      loading: false,
      tableData: [],
      form: {
        userId: "",
      },
    };
  },
  created() {
    // this.getList();
  },
  methods: {
    handleQuery(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.getList()
        } else {
          return false;
        }
      });
    },
    getList() {
      this.loading = true;
      userContributionStatistics({
        ...this.form
      }).then(res => {
        this.loading = false;
        let list = res.result.coinInfoList.map(item => {
          item.userId = res.result.userId
          item.userAccount = res.result.userAccount
          return item
        })
        this.tableData = list
      }).catch(err => {
        this.loading = false;
      })
    }
  }
};
</script>

<style></style>
